import re
from typing import Dict


class Career(Dict):
    def __init__(self, info_str) -> None:
        self.info = info_str
        self["职业名称"] = self.__match(r"(?<=\|)职业名称=(.*?)(?=\n)")
        self["职业类型"] = self.__match(r"(?<=\|)职业类型=(.*?)(?=\n)")
        self["职业阶级"] = self.__match(r"(?<=\|)职业阶级=(.*?)(?=\n)")
    
    def __match(self, format):
        value = re.search(format, self.info, re.MULTILINE)
        return value.group(1) if value else ""